﻿<UserControl
    x:Class="TfsWorkbench.WpfUI.Controls.MainMenuControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:UIElements="clr-namespace:TfsWorkbench.UIElements;assembly=TfsWorkbench.UIElements" 
    xmlns:Properties="clr-namespace:TfsWorkbench.WpfUI.Properties" 
    xmlns:DataObjects="clr-namespace:TfsWorkbench.Core.DataObjects;assembly=TfsWorkbench.Core" 
    Name="PART_MainMenu"
    >
    <UserControl.Resources>
    	<ResourceDictionary>
    		<ResourceDictionary.MergedDictionaries>
    			<ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/ApplicationStyles.xaml"/>
                <ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/CommandButtonStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <DataTemplate x:Key="EditMenuItem" DataType="{x:Type DataObjects:ViewMap}">
                <MenuItem 
    				Header="{Binding Title}" 
    				CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
    				Command="{x:Static UIElements:CommandLibrary.EditViewCommand}"
    				CommandParameter="{Binding}"
                />
            </DataTemplate>
            <DataTemplate x:Key="DeleteMenuItem" DataType="{x:Type DataObjects:ViewMap}">
                <MenuItem 
    				Header="{Binding Title}" 
    				CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
    				Command="{x:Static UIElements:CommandLibrary.DeleteViewCommand}"
    				CommandParameter="{Binding}"
                />
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>
    <Menu Name="PART_TopMenu" Background="{StaticResource MenuBackground}">
        <MenuItem Header="File">
            <MenuItem Command="{x:Static UIElements:CommandLibrary.LoadProjectCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
            <MenuItem Command="{x:Static UIElements:CommandLibrary.SaveProjectCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" InputGestureText="[Ctrl] + [Shift] + S">
                <MenuItem.Icon>
                    <ContentControl 
                        Template="{StaticResource SaveIconTemplate}" 
						Style="{StaticResource MenuIconStyle}"
                        />
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Command="{x:Static UIElements:CommandLibrary.CloseProjectCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
                <MenuItem.Icon>
                    <ContentControl 
                        Template="{StaticResource CloseIconTemplate}" 
						Style="{StaticResource MenuIconStyle}"
                        />
                </MenuItem.Icon>
			</MenuItem>
            <MenuItem Command="{x:Static UIElements:CommandLibrary.RefreshProjectDataCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" InputGestureText="[Ctrl] + [Shift] + R">
                <MenuItem.Icon>
                    <ContentControl 
						Style="{StaticResource MenuIconStyle}"
                        Template="{StaticResource RefreshIconTemplate}" 
                        />
                </MenuItem.Icon>
			</MenuItem>
            <MenuItem Command="{x:Static UIElements:CommandLibrary.ResetProjectLayoutCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
                <MenuItem.Icon>
                    <ContentControl 
						Style="{StaticResource MenuIconStyle}"
                        Template="{StaticResource DeleteIconTemplate}" 
                        />
                </MenuItem.Icon>
            </MenuItem>
            <Separator />
            <MenuItem Command="{x:Static UIElements:CommandLibrary.ExitCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
        </MenuItem>
        <MenuItem Header="Settings">
            <MenuItem Command="{x:Static UIElements:CommandLibrary.EditTypeDataCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource EditIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>
            
            <Separator />
            
            <MenuItem Command="{x:Static UIElements:CommandLibrary.AddViewCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource AddIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>

            <MenuItem Header="Edit View" Name="PART_ViewEditMenu" ItemsSource="{Binding ElementName=PART_MainMenu, Path=ProjectData.ViewMaps}" ItemTemplate="{StaticResource EditMenuItem}">
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource EditIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>

            <MenuItem Header="Delete View" Name="PART_ViewDeleteMenu" ItemsSource="{Binding ElementName=PART_MainMenu, Path=ProjectData.ViewMaps}" ItemTemplate="{StaticResource DeleteMenuItem}">
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource DeleteIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>

        </MenuItem>
        <MenuItem Name="PART_ViewMenu" Header="View">
            
            <MenuItem Command="{x:Static UIElements:CommandLibrary.ShowSearchDialogCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" InputGestureText="[Ctrl] + F"> 
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource FindIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>

            <MenuItem Command="{x:Static UIElements:CommandLibrary.ClearHighlightsCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" InputGestureText="[Ctrl] + [Shift] + Z">
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource DeleteIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>

            <MenuItem Command="{x:Static UIElements:CommandLibrary.CloseAllDialogsCommand}" CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" InputGestureText="[Ctrl] + [Shift] + D">
                <MenuItem.Icon>
                    <ContentControl Template="{StaticResource CloseIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                </MenuItem.Icon>
            </MenuItem>

            <Separator />
            
        </MenuItem>

        <MenuItem Name="PART_PlugInMenu" Header="Tools">
        </MenuItem>
        
        <MenuItem Header="Help">
            <MenuItem Command="{x:Static UIElements:CommandLibrary.ShowAboutCommand}" CommandTarget="{Binding ElementName=PART_MainMenu}">
                <MenuItem.Icon>
                    <ContentControl 
						Style="{StaticResource MenuIconStyle}"
                        Template="{StaticResource QuestionIconTemplate}" 
                        />
                </MenuItem.Icon>
			</MenuItem>
            <MenuItem 
                Header="Online Help"
                Command="{x:Static UIElements:CommandLibrary.SystemShellCommand}" 
                CommandParameter="{Binding Source={x:Static Properties:Settings.Default}, Path=Default.HelpPageUrl}"
                CommandTarget="{Binding ElementName=PART_MainMenu}">
                <MenuItem.Icon>
                    <ContentControl 
						Style="{StaticResource MenuIconStyle}"
                        Template="{StaticResource WebIconTemplate}" 
                        />
                </MenuItem.Icon>
            </MenuItem>
            <Separator />
            <MenuItem Click="Gc" Header="GC" />
        </MenuItem>
    </Menu>    
</UserControl>